package springboot.common;

public class Result {

	private String code;
	private Object data;
	private String msg;
	
	private final static transient String SUCCESS_CODE="200";
	private final static transient String ERROR_CODE="400";
	
	private Result() {
		
	}
	
	public static Result success() {
		return new Result().setCode(SUCCESS_CODE);
	}
	
	public static Result success(Object obj) {
		return new Result().setCode(SUCCESS_CODE).setData(obj);
	}
	
	public static Result error(String msg) {
		return new Result().setCode(ERROR_CODE).setMsg(msg);
	}

	public String getCode() {
		return code;
	}

	public Result setCode(String code) {
		this.code = code;
		return this;
	}

	public Object getData() {
		return data;
	}

	public Result setData(Object data) {
		this.data = data;
		return this;
	}

	public String getMsg() {
		return msg;
	}

	public Result setMsg(String msg) {
		this.msg = msg;
		return this;
	}
	
}
